const Mock = require('mockjs')
const Random = Mock.Random

/**
 * 首页新闻数据
 */
Mock.mock('/api/news_index', {
  code: 200,
  msg: 'ok',
  data: {
    'newsData|6-7': [
      {
        type: '@title(1)',
        'typeid|+1': 1,
        'news|7': [
          {
            'id|+1': 0,
            title: '@ctitle(10,33)',
            createTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
            creator: '@cname',
            'status|0-1': 1,
            'isTop|0-1': 1,
            'iscarousel|0-1': 0,
            sourceAddress: '@url("http")',
            'browsing|+1': 0,
            fsource: '@ctitle(4,7)',
            content: '@cparagraph(2, 5)',
            imageUrl: Random.image('220x100', Random.color(), Random.sentence(3, 5))
          }
        ],

      }
    ],
    'customerCoin|8': [
      {
        'id|+1': 0,
        icon: Random.image('45x45', Random.color()),
        name: '@title(1)',
        cname: '@ctitle(2,3)',
        url: '@url("http")'
      }
    ],
    'famousePerson|8': [
      {
        'id|+1': 0,
        name: '@cname(3)',
        avatar: Random.image('145x145', Random.color()),
        desc: '@cword()'
      }
    ]
  }
  ,
  token: Random.guid()
})

/**
 * 列表页新闻数据 附带热门新闻
 */

Mock.mock(/\/api\/news_list[\s\S]*/, {
  code: 200,
  msg: 'ok',
  'data': {
    'newsTypes|7': [
      {
        type: '@title(1)',
        'typeid|+1': 1,
      }
    ],
    'news|7': [
      {
        'id|+1': 0,
        title: '@ctitle(10,33)',
        createTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
        creator: '@cname',
        'status|0-1': 1,
        'isTop|0-1': 1,
        'iscarousel|0-1': 0,
        sourceAddress: '@url("http")',
        'browsing|+1': 0,
        fsource: '@ctitle(4,7)',
        content: '@cparagraph(2, 5)',
        imageUrl: Random.image('420x300', Random.color(), Random.sentence(3, 5))
      }
    ],
    total: 30,
    pageSize: 10,
    'hotDayNews|7': [
      {
        'id|+1': 100,
        title: '@ctitle(10,33)'
      }
    ],
    'hotWeekNews|7': [
      {
        'id|+1': 100,
        title: '@ctitle(10,33)'
      }
    ]
  },
  token: Random.guid()
})

/**
 * 新闻详情
 */
Mock.mock(/\/api\/news_detail[\s\S]*/, {
  code: 200,
  msg: 'ok',
  data: {
    newsType: {
      type: '@title(1)',
      'typeid|+1': 1,
    },
    news: {
      'id|+1': 0,
      title: '@ctitle(10,33)',
      createTime: '@datetime("yyyy-MM-dd HH:mm:ss")',
      creator: '@cname',
      'status|0-1': 1,
      'isTop|0-1': 1,
      'iscarousel|0-1': 0,
      sourceAddress: '@url("http")',
      'browsing|+1': 0,
      fsource: '@ctitle(4,7)',
      content: '@cparagraph(20, 50)',
      imageUrl: Random.image('420x300', Random.color(), Random.sentence(3, 5))
    },
    preNews: {
      'id|+1': 30,
      title: '@ctitle(10,33)'
    },
    nextNews: {
      'id|+1': 50,
      title: '@ctitle(10,33)'
    },
    'hotNews|7': [
      {
        'id|+1': 100,
        title: '@ctitle(10,33)',
        'browsing|+1': 0,
        fsource: '@ctitle(3,5)',
        imageUrl: Random.image('420x300', Random.color(), Random.sentence(3, 5))
      }
    ],

  },
  token: Random.guid()
})

